package hcn.protocol.brandnew.zhenliao.zhenduan;

import com.fasterxml.jackson.annotation.JsonFormat;
import ctd.util.xml.jaxb.DateTimeAdapter;
import hcn.protocol.brandnew.BaseRequest;
import lombok.Data;
import org.atag.sysrouter.annotation.DictionaryMapping;

import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.Date;
import java.util.List;


/**
 * 门诊处方信息新增 - ODS_03040001
 *
 * @author enjoyLife
 */
@Data
@XmlRootElement(name = "MsgBody")
@XmlAccessorType(XmlAccessType.FIELD)
public class SavePrescriptionInformationRequest extends BaseRequest {

    /**
     * 患者基本信息
     */
    @XmlElement(name = "Patient")
    private Patient patient;
    /**
     * 就诊信息
     */
    @XmlElement(name = "Visit")
    private Visit visit;
    /**
     * 处方信息
     */
    @XmlElementWrapper(name = "RecipeLists")
    @XmlElement(name = "RecipeList")
    private List<RecipeList> recipeLists;

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Patient {

        /**
         * 就诊医疗机构组织机构代码
         */
        @XmlElement(name = "VisitOrganization")
        private String visitOrganization;
        /**
         * 区域内患者唯一标识
         */
        @XmlElement(name = "MPI")
        private String mpi;
        /**
         * 身份证件号码
         */
        @XmlElement(name = "IdCard")
        private String idCard;
        /**
         * 身份证件类别代码
         */
        @XmlElement(name = "IdCardCode")
        @DictionaryMapping(id = "CV02_01_101")
        private String idCardCode;
        /**
         * 业务系统患者档案ID
         */
        @XmlElement(name = "SourcePatientId")
        private String sourcePatientId;
        /**
         * 就诊卡类别代码
         */
        @XmlElement(name = "MedicalCardType")
        private String medicalCardType;
        /**
         * 就诊卡号
         */
        @XmlElement(name = "MedicalCardId")
        private String medicalCardId;
        /**
         * 医疗机构院区标识
         */
        @XmlElement(name = "HosArea")
        private String hosArea;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Visit {

        /**
         * 门（急）诊号
         */
        @XmlElement(name = "ClinicId")
        private String clinicId;
        /**
         * 住院号
         */
        @XmlElement(name = "HospizationId")
        private String hospizationId;
        /**
         * 患者年龄
         */
        @XmlElement(name = "Age")
        private Short age;
        /**
         * 患者类型代码
         */
        @XmlElement(name = "PatientType")
        private String patientType;
        /**
         * 就诊流水号
         */
        @XmlElement(name = "VisitId")
        private String visitId;
        /**
         * 挂号流水号
         */
        @XmlElement(name = "OutRegistryId")
        private String outRegistryId;

        /**
         * 患者性别
         */
        @XmlElement(name = "Sex")
        private String sex;
        /**
         * 患者姓名
         */
        @XmlElement(name = "Name")
        private String name;
        /**
         * 年龄（月）
         */
        @XmlElement(name = "MonthAge")
        private String monthAge;
        /**
         * 身高（cm）
         */
        @XmlElement(name = "Height")
        private String height;
        /**
         * 体重（kg）
         */
        @XmlElement(name = "Weight")
        private String weight;
        /**
         * 体检科室代码
         */
        @XmlElement(name = "DeptCode")
        private String deptCode;
        /**
         * 科室名称
         */
        @XmlElement(name = "DeptName")
        private String deptName;
        /**
         * 接诊医生
         */
        @XmlElement(name = "DoctorCode")
        private String doctorCode;
        /**
         * 检验医师签名
         */
        @XmlElement(name = "Doctor")
        private String doctor;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class PrescriptionDrug {

        /**
         * 药物代码
         */
        @XmlElement(name = "DrugsNumber")
        private String drugsNumber;
        /**
         * 药物使用频次代码
         */
        @XmlElement(name = "DrugUsingRate")
        private String drugUsingRate;
        /**
         * 药物使用途径代码
         */
        @XmlElement(name = "DrugUsePathwaysCode")
        private String drugUsePathwaysCode;
        /**
         * 药品产地id
         */
        @XmlElement(name = "DrugProductionPlaceId")
        private String drugProductionPlaceId;
        /**
         * 一次剂量
         */
        @XmlElement(name = "OnceDosage")
        private String onceDosage;
        /**
         * 剂量单位
         */
        @XmlElement(name = "DosageUnit")
        private String dosageUnit;
        /**
         * 药品-用药天数
         */
        @XmlElement(name = "MedicineDays")
        private Short medicineDays;
        /**
         * 草药脚注
         */
        @XmlElement(name = "HerbalFootNote")
        private String herbalFootNote;
        /**
         * 草药煎法代码
         */
        @XmlElement(name = "HerbalMedicineDecoction")
        private Integer herbalMedicineDecoction;
        /**
         * 药物发放数量
         */
        @XmlElement(name = "DrugSendNumber")
        private String drugSendNumber;
        /**
         * 中药饮片剂数
         */
        @XmlElement(name = "PiecesChineseMedicineAgentNumb")
        private Byte piecesChineseMedicineAgentNumb;
        /**
         * 处方药品组号
         */
        @XmlElement(name = "DrugsGroupNumber")
        private String drugsGroupNumber;
        /**
         * 药品顺序号
         */
        @XmlElement(name = "SortNumber")
        private String sortNumber;
        /**
         * 备注信息
         */
        @XmlElement(name = "Remark")
        private String remark;
        /**
         * 外部处方明细id
         */
        @XmlElement(name = "OnlinePrescriptionDetailId")
        private String onlinePrescriptionDetailId;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class RecipeList {
        /**
         * 建档机构
         */
        @XmlElement(name = "VisitOrganization")
        private String visitOrganization;

        /**
         * 药房编码
         */
        @XmlElement(name = "PharmacyId")
        private String pharmacyId;
        /**
         * 药物类型代码
         */
        @XmlElement(name = "DrugType")
        private String drugType;
        /**
         * 处方记录号
         */
        @XmlElement(name = "PrescriptionRecordId")
        private String prescriptionRecordId;
        /**
         * 中药饮片剂数
         */
        @XmlElement(name = "PiecesChineseMedicineAgentNumb")
        private Byte piecesChineseMedicineAgentNumb;
        /**
         * 代煎标志
         */
        @XmlElement(name = "BoilSign")
        private Byte boilSign;
        /**
         * 手术类别
         */
        @XmlElement(name = "OperationType")
        private String operationType;
        /**
         * 外延标志
         */
        @XmlElement(name = "EpitaxialSign")
        private Byte epitaxialSign;
        /**
         * 处方编号
         */
        @XmlElement(name = "RecipeNumber")
        private String recipeNumber;
        /**
         * 处方开立日期
         */
        @XmlElement(name = "PrescriptionDate")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date prescriptionDate;
        /**
         * 处方开立科室名称
         */
        @XmlElement(name = "PrescriptionDept")
        private String prescriptionDept;
        /**
         * 处方开立医师签名
         */
        @XmlElement(name = "PrescriptionDoctor")
        private String prescriptionDoctor;
        /**
         * 发票号码
         */
        @XmlElement(name = "InvoiceCode")
        private String invoiceCode;
        /**
         * 处方机构
         */
        @XmlElement(name = "RecipeOrganization")
        private String recipeOrganization;
        /**
         * 流转机构
         */
        @XmlElement(name = "RoamOrganization")
        private String roamOrganization;
        /**
         * 外部处方id
         */
        @XmlElement(name = "OnlinePrescriptionRecordId")
        private String onlinePrescriptionRecordId;
        /**
         * 处方药品信息
         */
        @XmlElementWrapper(name = "PrescriptionDrugs")
        @XmlElement(name = "PrescriptionDrug")
        private List<PrescriptionDrug> prescriptionDrugs;
    }

}
